from flightanalysis import Section, get_schedule
from flightplotting.plots import plotsec, plotdtw
import plotly
plotly.offline.init_notebook_mode()
flown = Section.from_csv("examples/P23.csv").subset(102, 475)
plotsec(flown).update_layout(width=1200, height=600)
p23 = get_schedule("F3A", "P23")
template = p23.scale_distance(170).create_raw_template("left", 30.0, 170.0)
plotsec(template).update_layout(width=1200, height=600)
dist, aligned = Section.align(flown, template)
plotdtw(aligned, p23.manoeuvres).update_layout(width=800,height=600)
manid = 0
subsec = p23.manoeuvres[manid].get_data(aligned)
plotdtw(subsec, p23.manoeuvres[manid].elements).update_layout(width=800,height=600)
corrected_p23 = p23.match_intention(aligned).correct_intention()
corrected_template = corrected_p23.create_matched_template(aligned)
manid = 0
fig = plotsec(p23.manoeuvres[manid].get_data(aligned))
fig.add_traces(plotsec(p23.manoeuvres[manid].get_data(corrected_template), color="blue").data)
fig.update_layout(width = 1200, height=600).show()